USE NutritionTracker
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'AppUser_AppRole') AND type in (N'U'))
	DROP TABLE AppUser_AppRole
GO
CREATE TABLE	AppUser_AppRole
(
	AppUserID	INT NOT NULL,
	AppRoleID	TINYINT NOT NULL,
	CONSTRAINT pk_AppUser_AppRole PRIMARY KEY(AppUserID ASC,AppRoleID ASC)
)
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'fk_AppUser_AppRole_AppUser') AND parent_object_id = OBJECT_ID(N'AppUser_AppRole'))
	ALTER TABLE AppUser_AppRole  WITH CHECK ADD  CONSTRAINT fk_AppUser_AppRole_AppUser FOREIGN KEY(AppUserID) REFERENCES AppUser (AppUserID)
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'fk_AppUser_AppRole_AppRole') AND parent_object_id = OBJECT_ID(N'AppUser_AppRole'))
	ALTER TABLE AppUser_AppRole  WITH CHECK ADD  CONSTRAINT fk_AppUser_AppRole_AppRole FOREIGN KEY(AppRoleID) REFERENCES AppRole (AppRoleID)
GO